<?php
/**
	Sponsor Manager (users.php file)
    Copyright (C) <Mon Apr 14 08:37:35 CEST 2008>  Marcos Ramírez <marcosramirez@gmail.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    
    Purpose:
    Last Modified:
**/
global $Cfg;
global $html;
global $sm;
global $user;

if ($_SESSION['nouser']==1) // First user
	$html->addInfo(_('Welcome to Sponsor Manager v').version._(' Please, create your Admin Account.'));
if ($_POST['userlogin'] && $_POST['userpass'] && $_POST['usermail']) {
	// This MUST return VIA ajax.
	$result=$user->addUser($_POST['userlogin'], $_POST['userpass'],$_POST['usermail']);
	if ($result==0) // Esta parte, debe ser AJAX.
		$html->addInfo(_('Usuario dado de alta'));
	else 
		$html->addInfo(_('Se produjo un error'));
		
}

$html->header();
?>

		<form id="newUser" method="post" action="<?=$Cfg['Sys']['webDir']?>?section=users">
		User: <input type="text" name="userlogin" /><br />
		Pass: <input type="text" name="userpass" /><br />
		Email: <input type="text" name="usermail" /><br />
		<input type="submit" value="<?=_('Submit')?>" />
		</form>

<?php
//show users list for... nothing xD
$result=$sm->Query("SELECT username FROM Sys_users");
while ($Res=$sm->Fetch($result)) 
	$userList.='<li>'.$Res['username'].'</li>';
echo "<ul>$userList</ul>";


$html->footer();
?>